package com.ruoyi.buss.dxts.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.buss.dxts.domain.DataCustDxts;
import com.ruoyi.buss.dxts.service.IDataCustDxtsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 短信推送功能Controller
 * 
 * @author zjh
 * @date 2021-08-02
 */
@RestController
@RequestMapping("/sms")
public class DataCustDxtsController extends BaseController
{
    @Autowired
    private IDataCustDxtsService dataCustDxtsService;    

    /**
     * 查询短信推送功能列表
     */
    @PreAuthorize(hasPermi = "buss:sms:list")
    @GetMapping("/list")
    public TableDataInfo list(DataCustDxts dataCustDxts)
    {
        startPage();
        
        List<DataCustDxts> list = dataCustDxtsService.selectDataCustDxtsList(dataCustDxts);
        return getDataTable(list);
    }

    /**
     * 导出短信推送功能列表
     */
    @PreAuthorize(hasPermi = "buss:sms:export")
    @Log(title = "短信推送功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataCustDxts dataCustDxts) throws IOException
    {
        List<DataCustDxts> list = dataCustDxtsService.selectDataCustDxtsList(dataCustDxts);
        ExcelUtil<DataCustDxts> util = new ExcelUtil<DataCustDxts>(DataCustDxts.class);
        util.exportExcel(response, list, "短信推送功能数据");
    }

    /**
     * 获取短信推送功能详细信息
     */
    @PreAuthorize(hasPermi = "buss:sms:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dataCustDxtsService.selectDataCustDxtsById(id));
    }

    /**
     * 新增短信推送功能
     */
    @PreAuthorize(hasPermi = "buss:sms:add")
    @Log(title = "短信推送功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataCustDxts dataCustDxts)
    {
        return toAjax(dataCustDxtsService.insertDataCustDxts(dataCustDxts));
    }

    /**
     * 修改短信推送功能
     */
    @PreAuthorize(hasPermi = "buss:sms:edit")
    @Log(title = "短信推送功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataCustDxts dataCustDxts)
    {
        return toAjax(dataCustDxtsService.updateDataCustDxts(dataCustDxts));
    }

    /**
     * 删除短信推送功能
     */
    @PreAuthorize(hasPermi = "buss:sms:remove")
    @Log(title = "短信推送功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataCustDxtsService.deleteDataCustDxtsByIds(ids));
    }
}
